<?php


namespace app\services\cupboard;


use app\models\cupboard\FranchiserModel;
use app\services\BaseService;
use think\facade\Db;

class FranchiserService extends BaseService
{

    /**
     * 根据bdid获取加盟商id
     * @param array $bdId
     * @return array
     */
    public static function getFranchiserIdByBdId(array $bdId): array
    {
        $idArr = Db::connect('cupboard')->table('franchiser')->whereIn('bd_id', $bdId)->column('id');
        return $idArr;
    }

    protected static function initModel()
    {
        return new FranchiserModel();
    }

    /**
     * 获取商户信息
     * @param $franchiserId
     * @return array|mixed|\think\db\BaseQuery|\think\Model|null
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getFranchiserInfo($franchiserId)
    {
        $info = self::initModel()::find($franchiserId);
        return $info;
    }
}